HAL LPTIM I/O functions migration ¶
HAL LPTIM Input Capture (IC) Functions ¶
Important
Differences in starting and stopping LPTIM input capture between HAL1 and HAL2
In HAL1, starting and stopping LPTIM Input Capture (IC) in polling, interrupt, or DMA modes is managed solely through the respective start and stop APIs for the channel:
HAL_LPTIM_IC_StartHAL_LPTIM_IC_Start_ITHAL_LPTIM_IC_Start_DMA
In HAL2, the process involves two levels of control — the channel and the LPTIM peripheral itself. Starting and stopping Input Capture requires:
Starting or stopping the channel:
Start APIs:
HAL_LPTIM_IC_StartChannel,HAL_LPTIM_IC_StartChannel_IT,HAL_LPTIM_IC_StartChannel_DMAStop APIs:
HAL_LPTIM_IC_StopChannel,HAL_LPTIM_IC_StopChannel_IT,HAL_LPTIM_IC_StopChannel_DMA
Starting or stopping the LPTIM peripheral:
Start APIs:
HAL_LPTIM_Start,HAL_LPTIM_Start_IT,HAL_LPTIM_Start_DMAStop APIs:
HAL_LPTIM_Stop,HAL_LPTIM_Stop_IT,HAL_LPTIM_Stop_DMA
Important ordering rules in HAL2:
The LPTIM Start operation (
HAL_LPTIM_Start,_IT,_DMA) must be called only after all required channels have been started.The LPTIM Stop operation (
HAL_LPTIM_Stop,_IT,_DMA) must be called only after all required channels have been stopped.
This ensures proper synchronization between the peripheral and its channels, preventing potential issues during Input Capture operations. For more details, refer to Input Capture mode in other concepts
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Input Capture Configuration |
In HAL1, to configure the input channel, you need to call: HAL_StatusTypeDef HAL_LPTIM_IC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
const LPTIM_IC_ConfigTypeDef *sConfig,
uint32_t Channel);
|
In HAL2, to configure the input channel, you need to call: hal_status_t HAL_LPTIM_IC_SetConfigChannel(hal_lptim_handle_t *hlptim,
hal_lptim_channel_t channel,
const hal_lptim_ic_config_t *p_config);
|
|
Input Capture Start and Stop in polling mode |
In HAL1, the input capture in polling mode is managed using the following functions:
|
In HAL2, the polling mode is handled by:
|
|
Input Capture Start and Stop in interrupt mode |
In HAL1, the input capture in interrupt mode is managed using the following functions:
|
In HAL2, the interrupt mode is handled by:
|
|
Input Capture Start and Stop in DMA Mode |
In HAL1, the input capture in DMA mode is managed using the following functions:
|
In HAL2, the DMA mode is handled by:
Note In HAL2, users are provided with additional asynchronous process APIs (with suffixes _DMA_Opt and _IT_Opt) that enable selective filtering of optional interrupts. Specifically, in the HAL2 LPTIM driver, this feature is applied to the DMA process through the following API, which allows users to choose the desired DMA interrupt option or to operate the DMA in silent mode—that is, without generating any interrupt. hal_status_t HAL_LPTIM_IC_StartChannel_DMA_Opt(hal_lptim_handle_t *hlptim,
hal_lptim_channel_t channel,
const uint8_t *p_data,
uint32_t size_byte,
uint32_t interrupts);
Related concept: New APIs for filtering optional asynchronous process interrupts |
HAL LPTIM Output Compare (OC) Functions: ¶
Important
Differences in starting and stopping LPTIM in Output Compare (PWM, Set Once, One Pulse, timeout ) Between HAL1 and HAL2
In HAL1, starting and stopping LPTIM Output Compare (OC) in polling or interrupt modes is managed solely through the respective start and stop APIs for the channel:
HAL_LPTIM_PWM_Start,HAL_LPTIM_OnePulse_Start,HAL_LPTIM_SetOnce_Start,HAL_LPTIM_TimeOut_Start.HAL_LPTIM_PWM_Start_IT,HAL_LPTIM_OnePulse_Start_IT,HAL_LPTIM_SetOnce_Start_IT,HAL_LPTIM_TimeOut_Start_IT.HAL_LPTIM_PWM_Start_DMA
In HAL2, the process involves two levels of control — the channel and the LPTIM peripheral itself. Starting and stopping Output Compare requires:
Starting or stopping the channel:
Start APIs:
HAL_LPTIM_OC_StartChannel,HAL_LPTIM_OC_StartChannel_ITStop APIs:
HAL_LPTIM_OC_StopChannel,HAL_LPTIM_OC_StopChannel_IT
Starting or stopping the LPTIM peripheral:
Start APIs:
HAL_LPTIM_Start,HAL_LPTIM_Start_ITStop APIs:
HAL_LPTIM_Stop,HAL_LPTIM_Stop_IT
Important ordering rules in HAL2:
The LPTIM Start operation (
HAL_LPTIM_Start,_IT,_DMA) must be called only after all required channels have been started.The LPTIM Stop operation (
HAL_LPTIM_Stop,_IT,_DMA) must be called only after all required channels have been stopped.In HAL1, the API HAL_LPTIM_PWM_Start_DMA was provided to start the specified channel in output compare mode using DMA to update the CCR1 register (compare register). However, since the LPTIM peripheral does not support compare DMA requests, this function was not meaningful even in HAL1 and has been removed in HAL2. Users can still generate PWM signals using the polling and interrupt (IT) modes available in HAL2.
This ensures proper synchronization between the peripheral and its channels, preventing potential issues during Output Compare operations.
For more details, refer to LPTIM Counter output modes in other concepts
HAL LPTIM output compare configuration ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
const LPTIM_OC_ConfigTypeDef *sConfig,
uint32_t Channel);
|
hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
hal_lptim_channel_t channel,
const hal_lptim_oc_config_t *p_config);
|
HAL LPTIM PWM functions ¶
Important
In HAL1, there were a dedicated APIs specifically for PWM mode as shown in the following table.
In HAL2, The PWM specific APIs are removed. To generate a PWM output signal, user needs to call
HAL_LPTIM_SetConfig()API by selecting the modeHAL_LPTIM_CONTINUOUS.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Polling mode |
In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, polling mode is handled by the following sequence:
|
|
Interrupt mode |
In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, the interrupt mode is handled by the following sequence:
|
|
DMA mode |
In HAL1, the DMA mode for various timer functionalities is managed using specific functions:
|
Important In HAL1, the API HAL_LPTIM_PWM_Start_DMA() was provided to start the specified channel in output compare mode using DMA to update the CCR1 register (compare register). However, since the LPTIM peripheral does not support compare DMA requests, this function was not meaningful even in HAL1 and has been removed in HAL2. Users can still generate PWM signals using the polling and interrupt (IT) modes available in HAL2. |
Related use case: PWM generator with external clock
HAL LPTIM one pulse start/stop functions ¶
Important
In HAL1, there were a dedicated APIs specifically for one pulse mode as shown in the following table.
In HAL2, The one pulse mode specific APIs are removed. To generate a one pulse signal, user needs to call
HAL_LPTIM_SetConfig()API by selecting the modeHAL_LPTIM_ONE_SHOT.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Polling mode |
In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, polling mode is handled by the following sequence:
|
|
Interrupt mode |
In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, the interrupt mode is handled by the following sequence:
|
HAL LPTIM set once start/stop functions ¶
Important
In HAL1, there were a dedicated APIs specifically for set once mode as shown in the following table.
In HAL2, The set once specific APIs are removed. To generate a set once signal, user needs to call
HAL_LPTIM_SetConfig()API by selecting the modeHAL_LPTIM_SET_ONCE.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Polling mode |
In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, polling mode is handled by the following sequence:
|
|
Interrupt mode |
In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, the interrupt mode is handled by the following sequence:
|
HAL LPTIM timeout start/stop functions ¶
Important
In HAL1, there were a dedicated APIs specifically for timeout mode as shown in the following table.
In HAL2, The timeout APIs are removed. To activate the timeout mode, user needs to call
HAL_LPTIM_SetConfig()API by selecting the modeHAL_LPTIM_TIMEOUT.
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Polling mode |
In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, polling mode is handled by the following sequence:
|
|
Interrupt mode |
In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, the interrupt mode is handled by the following sequence:
|
HAL LPTIM encoder functions ¶
Refer to Other concepts
|
HAL1 |
HAL2 |
|
|---|---|---|
|
Polling mode |
In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, polling mode is handled by the following sequence:
|
|
Interrupt mode |
In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:
|
In HAL2, the interrupt mode is handled by the following sequence:
|
Related use case: encoder mode